%%-----------------------------------------------------------------------
%% Make your own quadrille, graph, hex, etc paper!
%% Uses the pgf/TikZ package for LaTeX, which should be part of
%% any modern TeX installation.
%% Email: mcnees@gmail.com
%% Twitter: @mcnees
%%-----------------------------------------------------------------------

\documentclass[11pt]{article}

%%-----------------------------------------------------------------------
%% This package gives small margins so you use less
%% paper.
%%-----------------------------------------------------------------------
\usepackage[cm]{fullpage}

%%-----------------------------------------------------------------------
%% Packages needed for the drawing routines and for mixing custom
%% colors.
%%-----------------------------------------------------------------------
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{xcolor}

%%-----------------------------------------------------------------------
%% A package for setting the background color of the page
%%-----------------------------------------------------------------------
\usepackage{pagecolor}

%%-----------------------------------------------------------------------
%% Which pattern style do we want?
%%-----------------------------------------------------------------------
% Names of patterns. These are basically enum values because I don't
% know how to really program in TeX.
\def\stdpat       {std}        % Standard, ten squares per inch (s.p.i.)
\def\stdeightpat  {stdeight}   % Standard, eight s.p.i.
\def\majminpat    {majmin}     % Eight s.p.i. w/ major grid ever 1/2 inch
\def\dotpat       {dot}        % Dot grid
\def\hexpat       {hex}        % Hex grid
\def\lightconepat {lightcone}  % Light cone grid

% Which pattern style to use. CHOOSE HERE by using one of the magic
% tokens above: std, stdeight, majmin, dot, hex, lightcone
\def\usepat{std}

%%-----------------------------------------------------------------------
%% Some nice colors.
%%-----------------------------------------------------------------------
\definecolor{plum}{rgb}{0.36078, 0.20784, 0.4}
\definecolor{chameleon}{rgb}{0.30588, 0.60392, 0.023529}
\definecolor{cornflower}{rgb}{0.12549, 0.29020, 0.52941}
\definecolor{scarlet}{rgb}{0.8, 0, 0}
\definecolor{brick}{rgb}{0.64314, 0, 0}
\definecolor{sunrise}{rgb}{0.80784, 0.36078, 0}


%%-----------------------------------------------------------------------
%% 2. Colors used for the minor, major, and null (diagonal) grids.
%%-----------------------------------------------------------------------
%% A light blue color for the minor grid.
\colorlet{minorcolor}{cornflower!35}
%% A darker blue color for the major grid and/or frame.
\colorlet{majorcolor}{cornflower!60}
%% You can make either one darker by changing the number after the "!".
%% For instance, cornflower!75 would be much darker.
% The color to use for the null directions.
\colorlet{lightlines}{scarlet!30}

%%-----------------------------------------------------------------------
%% Color used for the page background
%%-----------------------------------------------------------------------
\colorlet{bgcolor}{plum!10}

%%-----------------------------------------------------------------------
%% Comment out the previous lines and uncomment the following lines for
%% graph paper with a light green color, like on an engineering pad.
%%-----------------------------------------------------------------------
% \colorlet{minorcolor}{chameleon!30}
% \colorlet{majorcolor}{chameleon!50}
% \colorlet{bgcolor}{chameleon!10}

%%-----------------------------------------------------------------------
%% This section sets up a routine for filling a shape with
%% hexagons. Uses code from:
%% http://tex.stackexchange.com/questions/6019/drawing-hexagons/6128#6128
%%-----------------------------------------------------------------------

% Big hexagons
%\def\hexagonsize{0.1666in}
% Small hexagons
\def\hexagonsize{0.0833in}

\pgfdeclarepatternformonly
  {hexagons}% name
  {\pgfpointorigin}% lower left
  {\pgfpoint{3*\hexagonsize}{0.866025*2*\hexagonsize}}
  {\pgfpoint{3*\hexagonsize}{0.866025*2*\hexagonsize}}
  {
    \pgfsetlinewidth{0.6pt}
    \pgftransformshift{\pgfpoint{0mm}{0.866025*\hexagonsize}}
    \pgfpathmoveto{\pgfpoint{0mm}{0mm}}
    \pgfpathlineto{\pgfpoint{0.5*\hexagonsize}{0mm}}
    \pgfpathlineto{\pgfpoint{\hexagonsize}{-0.866025*\hexagonsize}}
    \pgfpathlineto{\pgfpoint{2*\hexagonsize}{-0.866025*\hexagonsize}}
    \pgfpathlineto{\pgfpoint{2.5*\hexagonsize}{0mm}}
    \pgfpathlineto{\pgfpoint{3*\hexagonsize+0.2mm}{0mm}}
    \pgfpathmoveto{\pgfpoint{0.5*\hexagonsize}{0mm}}
    \pgfpathlineto{\pgfpoint{\hexagonsize}{0.866025*\hexagonsize}}
    \pgfpathlineto{\pgfpoint{2*\hexagonsize}{0.866025*\hexagonsize}}
    \pgfpathlineto{\pgfpoint{2.5*\hexagonsize}{0mm}}
    \pgfusepath{stroke}
  }

%%-----------------------------------------------------------------------
%% This section sets up a routine for filling the squares in a
%% grid with null lines.
%%-----------------------------------------------------------------------
\def\squaresize{0.25in}
\pgfdeclarepatternformonly
  {lightcones}% name
  {\pgfpointorigin}% lower left
  {\pgfpoint{\squaresize}{\squaresize}}%  upper right
  {\pgfpoint{\squaresize}{\squaresize}}%  tile size
  {% shape description
    \pgfsetlinewidth{0.4pt}
    %Comment out this line for solid lines on light cones, instead of dashes.
    \pgfsetdash{{0.05cm}{0.05cm}}{0.025cm}
    \pgfpathmoveto{\pgfpoint{0in}{0in}}
    \pgfpathlineto{\pgfpoint{\squaresize}{\squaresize}}
    \pgfpathmoveto{\pgfpoint{0in}{\squaresize}}
    \pgfpathlineto{\pgfpoint{\squaresize}{0in}}
    \pgfusepath{stroke}
  }

%%-----------------------------------------------------------------------
%% This section sets up a routine for filling a region with dots
%% Slightly modified version of code added by Leo
%% Stein (@duetosymmetry on Twitter).
%%-----------------------------------------------------------------------
% Big squares
% \def\dotgridsquaresize{0.2in}
% Small squares
\def\dotgridsquaresize{0.1in}
\def\dotsize{.7pt}
\pgfdeclarepatternformonly
  {dotgrid}% name
  {\pgfpoint{-0.5*\dotgridsquaresize}{-0.5*\dotgridsquaresize}}% lower left
  {\pgfpoint{0.5*\dotgridsquaresize}{0.5*\dotgridsquaresize}}%  upper right
  {\pgfpoint{\dotgridsquaresize}{\dotgridsquaresize}}%  tile size
  {% shape description
    \pgfpathcircle{\pgfqpoint{0pt}{0pt}}{\dotsize}
    \pgfusepath{fill}
  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Document starts here
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

% No page numbers!
\thispagestyle{empty}

% Set the background color. Comment out this line for a white background. 
\pagecolor{bgcolor}

\begin{tikzpicture}[remember picture, overlay]

  % Change "very thin" to "thin" if the lines are too thin.
  \tikzset{
    minorgrid/.style={minorcolor, thin},
    majorgrid/.style={majorcolor, thin},
  }

%%-(Section)-------------------------------------------------------------

%%-----------------------------------------------------------------------
%% Use this section for quadrille, ten squares per inch.
%%-----------------------------------------------------------------------

\ifx\usepat\stdpat
% Draw a grid with 10 squares per inch.
\draw[style=minorgrid, shift={(current page.south west)},shift={(0.2in,0.2in)}] (0,0) coordinate (a) grid
[step=0.1in] (8.1in,10.6in) coordinate (b);

% Draw a frame around the grid.
\draw[style=majorgrid] (a) rectangle (b);
\fi

%%-(Section)-------------------------------------------------------------

%%-----------------------------------------------------------------------
%% Use this section for quadrille, eight squares per inch.
%%-----------------------------------------------------------------------

\ifx\usepat\stdeightpat
% Draw a grid with 10 squares per inch.
\draw[style=minorgrid, shift={(current page.south west)},shift={(0.1875in,0.1875in)}] (0,0) coordinate (a)
grid [step=0.125in] (8.125in,10.625in) coordinate (b);

% Draw a frame around the grid.
\draw[style=majorgrid] (a) rectangle (b);
\fi

%%-(Section)-------------------------------------------------------------

%%-----------------------------------------------------------------------
%% Use this part for graph, eight squares per inch with a major grid
%% every half-inch.
%%-----------------------------------------------------------------------

\ifx\usepat\majminpat
% Draw a grid with 10 squares per inch.
\draw[style=minorgrid, shift={(current page.south west)},shift={(0.225in,0.25in)}] (0,0) coordinate (a) grid [step=0.125in] (8in,10.5in) coordinate (b);

\draw[style=majorgrid, shift={(current page.south west)},shift={(0.225in,0.25in)}] (0,0) coordinate (a) grid [step=0.5in] (8in,10.5in) coordinate (b);

% Draw a frame around the grid.
\draw[style=majorgrid] (a) rectangle (b);
\fi

%%-(Section)-------------------------------------------------------------

%%-----------------------------------------------------------------------
%% Use this section to draw a dot grid on the page.
%% Slightly modified version of code added by Leo
%% Stein (@duetosymmetry).
%%-----------------------------------------------------------------------

\ifx\usepat\dotpat
\node at (current page.north west) [anchor=north west, inner sep=0pt, outer sep=0.18in]{
  \tikz{
    \fill [pattern=dotgrid,pattern color=minorcolor] (0.02,0) rectangle (8.14in,10.64in);
  }
};
\fi

%%-(Section)-------------------------------------------------------------

%%-----------------------------------------------------------------------
%% Use this section to draw a hex grid on the page.
%%-----------------------------------------------------------------------

\ifx\usepat\hexpat
\node at (current page.north west) [anchor=north west, inner sep=0pt, outer sep=0.0in]{
  \tikz{
    \fill [pattern=hexagons,pattern color=minorcolor] (0,0) rectangle (8.5in,11in);
  }
};
\fi

%%-(Section)-------------------------------------------------------------

%%-----------------------------------------------------------------------
%% Use this section to draw a grid with light cones.
%%-----------------------------------------------------------------------

\ifx\usepat\lightconepat
% Draw a grid with 4 squares per inch.
\draw[style=minorgrid, shift={(current page.south west)}] (0.25in,0.25in) coordinate (a) grid
[step=0.25in] (8.25in,10.75in) coordinate (b);

% Draw a border around the grid.
\draw[style=majorgrid] (a) rectangle (b);

% Now fill the grid with 45 degree lines in the color defined for null directions.
\node at (current page.south west) [anchor=south west, inner sep=0, style=majorgrid, shift={(a)}]{
  \tikz{
    \fill [pattern=lightcones,pattern color=lightlines] (0.25in,0.25in) rectangle (8.25in,10.75in);
  }
};
\fi

%%-(End)-------------------------------------------------------------
\end{tikzpicture}

\end{document}
